<?php

/**
 * PayPeriod form base class.
 *
 * @method PayPeriod getObject() Returns the current form's model object
 *
 * @package    virtualstore
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BasePayPeriodForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                     => new sfWidgetFormInputHidden(),
      'name'                   => new sfWidgetFormInputText(),
      'startDate'              => new sfWidgetFormDate(),
      'endDate'                => new sfWidgetFormDate(),
      'year'                   => new sfWidgetFormInputText(),
      'payment_periodicity_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('PaymentPeriodicity'), 'add_empty' => false)),
      'slug'                   => new sfWidgetFormInputText(),
      'created_at'             => new sfWidgetFormDateTime(),
      'updated_at'             => new sfWidgetFormDateTime(),
      'created_by'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('created_by_fk'), 'add_empty' => false)),
      'updated_by'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('updated_by_fk'), 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'id'                     => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'name'                   => new sfValidatorString(array('max_length' => 100)),
      'startDate'              => new sfValidatorDate(),
      'endDate'                => new sfValidatorDate(),
      'year'                   => new sfValidatorPass(),
      'payment_periodicity_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('PaymentPeriodicity'))),
      'slug'                   => new sfValidatorString(array('max_length' => 120, 'required' => false)),
      'created_at'             => new sfValidatorDateTime(),
      'updated_at'             => new sfValidatorDateTime(),
      'created_by'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('created_by_fk'))),
      'updated_by'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('updated_by_fk'))),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'PayPeriod', 'column' => array('slug')))
    );

    $this->widgetSchema->setNameFormat('pay_period[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'PayPeriod';
  }

}
